﻿/* Copyright (C) Siemens AG, 2012. All Rights Reserved.
 * Author: Roland Eckl, Corporate Technology
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System.ServiceModel;


namespace RVM.Infrastructure.Communication
{
    /// <summary>
    /// Delegate for the RemotePropertyChanged event.
    /// </summary>
    /// <param name="id">Unique ID of the ViewModel</param>
    /// <param name="property">Affected property</param>
    public delegate void RemotePropertyChangedDelegate(string id, string property);

    /// <summary>
    /// Delegate for the RemoteCollectionChanged event.
    /// </summary>
    /// <param name="id">Unique ID of the ViewModel</param>
    /// <param name="property">Affected property</param>
    /// <param name="details">Details on performed action</param>
    public delegate void RemoteCollectionChangedDelegate(string id, string property, CollectionChangedEventArgs details);

    /// <summary>
    /// ViewModelCallback interface.
    /// </summary>
    public interface IViewModelCallback
    {
        /// <summary>
        /// Raises RemotePropertyChanged event.
        /// </summary>
        /// <param name="id">Unique ID of the ViewModel</param>
        /// <param name="property">Affected property</param>
        [OperationContract(IsOneWay = true)]
        void FireRemotePropertyChanged(string id, string property);

        /// <summary>
        /// Raises RemoteCollectionChanged event.
        /// </summary>
        /// <param name="id">Unique ID of the ViewModel</param>
        /// <param name="property">Affected property</param>
        /// <param name="details">Details on performed action</param>
        [OperationContract(IsOneWay = true)]
        void FireRemoteCollectionChanged(string id, string property, CollectionChangedEventArgs details);

        /// <summary>
        /// Event which signals that some property of an exported ViewModel changed.
        /// </summary>
        event RemotePropertyChangedDelegate RemotePropertyChanged;

        /// <summary>
        /// Event which signals that some collection of an exported ViewModel changed.
        /// </summary>
        event RemoteCollectionChangedDelegate RemoteCollectionChanged;
    }
}
